@()
<script src="@routes.Assets.versioned("javascripts/jquery.js")" type="text/javascript"></script>
<h1>我的表单</h1>
<body>
	<input type="hidden" id="listingId" value="2a354">
	<form class="form_asset">
		<table>
			<tr>
				<th>属性集</th>
				<td>
					<select class="auto" name="attType">
						<option value="过期时间">过期时间</option>
						<option value="属性集一">属性集一</option>
						<option value="适宜人群">适宜人群</option>
					</select>
				</td>
			</tr>
		</table>
	</form>

	<button type="button" id="J_Btn"/>
</body>
<script>
$(document).on('change','.auto', function(){
	$(this).parents('tr').nextAll().remove();
	var content = '';
	$.ajax({
		method:'get',
		url:'/getOption',
		type:'text',
		async:false,
		success: function(data) {
			content += data;
		}
	});
	if($(this).val() == '属性集一') {
		$(this).parents('tr').after(content);
	}
});

$("#J_Btn").click(function(){

    var params = {};

    params['listingId'] = $('#listingId').val();

    var result = [];
    $(".form_asset").each(function(index){
        var data = $(this).serializeArray();
        var o = {};
        for(var i in data){
            o[data[i]['name']] = data[i]['value']
        }
        result.push(o);
    });
    params['asset'] = JSON.stringify(result);

    console.log(params);
    $.ajax({
        type:"post",
        url : "/saveAttrSet",
        data : JSON.stringify(params),
        contentType: "application/json",
        success:function(result){
            console.log(result);
        }
    });
});
</script>